#!/usr/bin/env python
# -*- coding: utf-8 -*-
#memojang.py

import sys
import time

def usage():
	print """
Usage
====
python %s -v : view memo
python %s -a : add memo
""" % (sys.argv[0], sys.argv[0])

#if not sys.argv[1] or sys.argv[1] not in ['-v', '-a']:		# 실행 오류
if not sys.argv[1:] or sys.argv[1] not in ['-v', '-a']:		# 정상 실행
	usage()
elif sys.argv[1] == '-v':
	try:
		print open("memo.txt").read()
	except IOError:
		print "memo.txt does not exist!"
elif sys.argv[1] == '-a':
	try:
		word = raw_input("input memo: ");
		f = open("memo.txt", "a")
		f.write(time.ctime() + ': ' + word + '\n')
		f.close()
		print "Line Added!"
	except:
		print "memo adding fails~!!!"
		f.close()
else:
	usage()
